package com.shiliao.app.activity.personal.presenter;

import android.text.TextUtils;

import com.shiliao.app.activity.personal.service.IMessageService;
import com.shiliao.app.activity.personal.service.impl.MessageImpl;
import com.shiliao.app.activity.personal.view.MessageView;
import com.shiliao.app.utils.YMServerUtil;
import com.yimei.framework.mvp.presenter.IBasePresenter;
import com.yimei.framework.network.ICallBack;
import com.yimei.framework.util.LogUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by yinzhiqiang on 2017/10/10.
 */

public class MessagePresenter extends IBasePresenter<IMessageService> {

    private MessageView messageView;
    private IMessageService messageService;

    public MessagePresenter(MessageView messageView) {
        this.messageView = messageView;
        messageService = new MessageImpl();
        setService(messageService);
    }

    public void requestMessage(String userId) {
        Map map = new HashMap();
        if (!TextUtils.isEmpty(userId)) {
            map.put("user_id", userId);
        }
        messageService.requestMessage(YMServerUtil.ACTION_MESSAGE, map, new ICallBack() {
            @Override
            public void onSuccess(int statusCode, Object result) {
                LogUtil.e("yzq", result.toString());
                messageView.getContent(result.toString());
            }

            @Override
            public void onFail(int statusCode, Object result) {
                LogUtil.e("yzq", result.toString());
                messageView.getContent(result.toString());
            }
        });

    }
}
